//! Consumer traits define the downstream sinks for OTLP batches.
//! Implementations should be non-blocking and thread-safe.

use pdata::internal::data::protogen::collector::logs::v1::ExportLogsServiceRequest;
use pdata::internal::data::protogen::collector::metrics::v1::ExportMetricsServiceRequest;
use pdata::internal::data::protogen::collector::trace::v1::ExportTraceServiceRequest;

/// Downstream sink for OTLP Traces batches.
#[tonic::async_trait]
pub trait ConsumeTraces: Send + Sync {
    /// Consume a batch of OTLP traces (ResourceSpans).
    ///
    /// self must be immutable, since this method will be called concurrently
    async fn consume(&self, data: ExportTraceServiceRequest);
}

/// Downstream sink for OTLP Metrics batches.
#[tonic::async_trait]
pub trait ConsumeMetrics: Send + Sync {
    /// Consume a batch of OTLP metrics (ResourceMetrics).
    ///
    /// self must be immutable, since this method will be called concurrently
    async fn consume(&self, data: ExportMetricsServiceRequest);
}

/// Downstream sink for OTLP Logs batches.
#[tonic::async_trait]
pub trait ConsumeLogs: Send + Sync {
    /// Consume a batch of OTLP logs (ResourceLogs).
    ///
    /// self must be immutable, since this method will be called concurrently
    async fn consume(&self, data: ExportLogsServiceRequest);
}
